<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>コントロールパネル</title>

    <link href="./assets/styles/default.css" rel="stylesheet" />
	<script src="./assets/scripts/libs/jquery-1.7.1.min.js" type="text/javascript"></script>
	<script src="./assets/scripts/import.js" type="text/javascript"></script>
	<script src="./assets/scripts/plugins/zip2address.js" type="text/javascript"></script>

</head>
<body>

{{$zhead}}

<div id="container">
	
{{$zmenu}}
    <article>
    	<h2><span>&nbsp;</span>会員管理<p><a href="javascript:;">Open Plugins</a></p></h2>
        <nav>
        	<ul>
					<li class="active"><a href="{{'Home/user/index'|U}}"><span>会員検索</span></a></li>
				  <li><a href="{{'Home/user/insert'|U}}"><span>会員登録</span></a></li>
			</ul>
        </nav>
		<section id="content">
			<h3>会員配送先情報</h3>

			<ul class="btns b20" style="position:relative;top:10px;">
			 <li class="btn left c"><a href="{{'Home/user/refer'|U}}?id={{$forms.id}}" >情報参照</a></li>
				<li class="btn center c"><a href="{{'Home/user/update'|U}}?id={{$forms.id}}" >情報更新</a></li>
				<li class="btn center c"><a href="{{'Home/delivery/refer'|U}}?id={{$forms.id}}" class="active">配送先情報</a></li>
				<li class="btn center c"><a href="{{'Home/order/index'|U}}?id={{$forms.id}}">注文情報</a></li>
				
				<li class="btn right c"><a href="{{'Home/mail/index'|U}}?id={{$forms.id}}" >メール履歴</a></li>
			</ul>

{{if $show_massg}}

			<form name="fm" action="{{'Home/delivery/update'|U}}" method="post" enctype="multipart/form-data">
				<h4><span>&nbsp;</span>基本情報</h4>
				<table class="formTable">
					<tbody>
					
					{{if !$show_massg2}}
						<tr>
							<th>登録日時</th>
							<td> {{$forms.c_time}}
								</td>
						</tr>
						<tr>
							<th>更新日時</th>
							<td> {{$forms.u_time}}
								<input type="hidden" name="u_date" value="" /></td>
						</tr>
						<tr>
							<th>システムID</th>
							<td>{{$forms.sent_id}}</td>
						</tr>{{/if}}
						<tr>
							<th class="must">配送先名</th>
							<td><input type="text" name="sent_name" value="{{$forms.sent_name}}" />{{$err_mes.sent_name}}</td>
						</tr>
						
						
						<tr>
							<th class="must">氏名</th>
							<td><input type="hidden" name="r_date" value="{{$forms.c_time}}" />
								<input type="hidden" name="id" value="{{$forms.id}}"  />
								<input type="hidden" name="sent_id" value="{{$forms.sent_id}}"  />
								<input type="text" class="short" name="sent_name1" value="{{$forms.sent_name1}}" />
								<input type="text" class="short" name="sent_name2" value="{{$forms.sent_name2}}" />{{$err_mes.sent_name1}}
							</td>
						</tr>
						<tr>
							<th>貴医院名・貴技工所名</th>
							<td><input type="text" name="sent_workshop_name" value="{{$forms.sent_workshop_name}}" />{{$err_mes.sent_workshop_name}}</td>
						<tr>
							<th class="must">郵便番号</th>
							<td class="floats">
								<input type="text" name="sent_zipcode1" class="short" value="{{$forms.sent_zipcode1}}" />
								<span> - </span>
								<input type="text" name="sent_zipcode2" class="short" value="{{$forms.sent_zipcode2}}" />{{$err_mes.sent_zipcode1}}
								<span class="btn_blank">
									<a href="javascript:;" style="position:relative;top:-2px;" class="searchAddress">住所検索</a>
								</span>
							</td>
						</tr>
						<tr>
							<th class="must">都道府県</th>
							<td>
								<select name="sent_local_cd" id='select_id'>
								  {{html_options options=$dao_local selected=$forms.sent_local_cd}}
								</select>{{$err_mes.sent_local_cd}}
							</td>
						</tr>
						<tr>
							<th class="must">市区町村</th>
							<td><input type="text" name="sent_treet_name" id="treet_name" class="text" value="{{$forms.sent_treet_name}}" />{{$err_mes.sent_treet_name}}</td>
						</tr>
						<tr>
							<th class="must">以降の住所</th>
							<td><input type="text" name="sent_address" class="text" value="{{$forms.sent_address}}" />{{$err_mes.sent_address}}</td>
						</tr>
						<tr>
							<th class="must">電話番号</th>
							<td>
								<input type="text" class="short" name="sent_tel_number1" value="{{$forms.sent_tel_number1}}" /> -
								<input type="text" class="short" name="sent_tel_number2" value="{{$forms.sent_tel_number2}}" /> -
								<input type="text" class="short" name="sent_tel_number3" value="{{$forms.sent_tel_number3}}" />
							{{$err_mes.sent_tel_number1}}</td>
						</tr>
					</tbody>
				</table>

				<p class="button">
					<button type="button" id="btn_update" class="submit"><span>更新</span></button>
				</p>
			</form>
		
		{{else}}
			<p class="message">{{$message}}</p>
			
			
			<ul class="result_btn clear" style="margin-top:20px;">
                <li><a href="{{'Home/delivery/refer'|U}}?id={{$forms.id}}">一覧に戻る</a></li>
                <li><a href="{{'Home/delivery/form'|U}}?id={{$forms.id}}">続けて新規登録する</a></li>
          
        	</ul>
			
		{{/if}}	
		
		</section>
	</article>
</div>
<script type="text/javascript">
		$(function(){
	//search address
		$('.searchAddress').live('click',function(){
			
			var p = $(this).closest("td");
			var table = $(this).closest("table");
			var post1 = $('input[name=sent_zipcode1]').val();
			var post2 = $('input[name=sent_zipcode2]').val();
			if(post1 == "" || post2 == ""){return;}
			var post = post1 +""+ post2;
			
			zip2address(post, function(address) {
			if (address) {
				
				$("#treet_name").val(address.city);
				$("#uniform-select_id>span").text(address.pref);
				//$("#select_id ").val(address.index);
				$("#select_id").children().attr("selected",false);
				  $("#select_id").find("option[value='"+(address.index+1)+"']").attr("selected",true);
			
			
			}
			else {
				alert("見つかりませんでした。。\n入力した郵便番号に誤りがないか、お確かめ下さい。");
			}
		});
			
		});
		});
</script>
{{$zfooter}}
</body>
</html>